const Koa = require("koa2");
const app = new Koa();
// const router = require("koa-router")();
const parser = require("koa-parser")
app.use(parser())
const cors = require("koa-cors")
app.use(cors())
// const { jwt, sessionConfig } = require("./config")
// const session = require("koa-session")
app.keys = ["secret"]

// app.use(session(sessionConfig,app))

// const koa_jwt = require("koa-jwt")
// const need_token = koa_jwt({ secret: jwt.secret })

// require("./model/sync")

const userRouterApi = require("./router/apis/user/user")
const roleRouterApi = require("./router/apis/user/role")
const ruleRouterApi = require("./router/apis/user/rule")
const catelogueRouterApi = require("./router/apis/catelogue/catelogue")
const chapterRouterApi = require("./router/apis/catelogue/chapter")
const questiontypeApi = require("./router/apis/question/questiontype")
const choiceApi = require("./router/apis/question/choice")

app.use(userRouterApi.routes())
app.use(roleRouterApi.routes())
app.use(ruleRouterApi.routes())
app.use(catelogueRouterApi.routes())
app.use(chapterRouterApi.routes())
app.use(questiontypeApi.routes())
app.use(choiceApi.routes())


// app.use(userRouterApi.routes()).use(need_token)
// app.use(roleRouterApi.routes()).use(need_token)
// app.use(ruleRouterApi.routes()).use(need_token)
// app.use(catelogueRouterApi.routes()).use(need_token)
// app.use(chapterRouterApi.routes()).use(need_token)
app.listen(3000, () => {
    console.log("服务器已经启动 端口 3000")
})